
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>基本列表渲染</title>
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
</head>
<body>
    <div id="root">
        
        <ul>
            <h2>人员列表</h2>
            <!-- 遍历数组 -->
            <!-- <li v-for="person in persons" :key="person.id">{{person.name}}-{{person.age}}</li> -->
            <!-- 多个参数最好加个小括号 -->
            <li v-for="(p,index) in persons" :key="p.id" >
                {{p}} --- {{index}} 
            </li>

            <h2>遍历对象</h2>
            <!-- 遍历对象 -->
            <li v-for="(value,k) in car"  >
                {{k}} --- {{value}} 
            </li>

            <h2>遍历字符串</h2>
            <!-- 遍历字符串 -->
            <li v-for="(char,index) in str"  >
                {{char}} --- {{index}} 
            </li>
        </ul>
    </div>
</body>
<script type="text/javascript">
    Vue.config.productionTip = false

    new Vue({
        el:'#root',
        data:{
            persons:[
                {id:'001',name:'张三 ',age:18},
                {id:'002',name:'李四',age:19},
                {id:'003',name:'王五',age:18}
            ],
            car:{
                name:'宝骏550',
                price:'5w'
            },
            str:'hello'
        },
    })
</script>
</html>